import { ref } from 'vue'
import { defineStore } from 'pinia'
//数据存储
export const useDataStore = defineStore('tableData', () => {
  const tableData = ref([]) //首页
  const imageTableData = ref([]) //图片
  const videoTableData = ref([]) //视频
  const audioTableData = ref([]) //音频
  const textTableData = ref([]) //文档
  const otherTableData = ref([]) //其他
  const setData = (data) => {
    //    设置数据去小数
    // .forEach((item) => {
    //   if (item.fileSize < 1024) {
    //     item.fileSize = Math.floor(item.fileSize) + 'KB'
    //   } else {
    //     item.fileSize = Math.floor(item.fileSize / 1024) + 'MB'
    //   }
    // })

    tableData.value = data
  }
  const setimageTableData = (data) => {
    imageTableData.value = data
  }
  const setvideoTableData = (data) => {
    videoTableData.value = data
  }
  const setaudioTableData = (data) => {
    audioTableData.value = data
  }
  const settextTableData = (data) => {
    textTableData.value = data
  }
  const setotherTableData = (data) => {
    otherTableData.value = data
  }
  const getData = () => {
    //    获取数据
    // tableData.value=xxx
    return tableData.value
  }
  return {
    tableData,
    imageTableData,
    videoTableData,
    audioTableData,
    textTableData,
    otherTableData,
    getData,
    setData,
    setimageTableData,
    setvideoTableData,
    setaudioTableData,
    settextTableData,
    setotherTableData
  }
})
